/**
 * @file wa_anim.h
 *
 */


#ifndef _WA_ANIM_H
#define _WA_ANIM_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************
*      INCLUDES
*********************/
#include "wa_conf.h"
#if USE_WA_ANIM != 0
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include "wa_misc.h"
#include "wa_ll.h"
/*********************
*      DEFINES
*********************/
#define WA_ANIM_REPEAT_INFINITE      0xFFFF
#define WA_ANIM_PLAYTIME_INFINITE    0xFFFFFFFF
/**********************
*      TYPEDEFS
**********************/
typedef enum 
{
	WA_ANIM_OFF,
	WA_ANIM_ON,
}wa_anim_enable_t;

struct _wa_anim;

typedef int32_t(*wa_anim_path_cb)(struct _wa_anim*);
typedef void (*wa_anim_exec_xcb)(void*, int32_t);
typedef void (*wa_anim_custom_exec_cb)(struct _wa_anim*, int32_t);
typedef void (*wa_anim_finish_cb)(struct _wa_anim*);
typedef void (*wa_anim_start_cb)(struct _wa_anim*);
typedef int32_t(*wa_anim_get_value_cb)(struct _wa_anim*);
typedef void (*wa_anim_deleted_cb)(struct _wa_anim*);

typedef struct _wa_anim
{
	void* var;
	wa_anim_exec_xcb exec_cb;
	wa_anim_start_cb start_cb;
	wa_anim_finish_cb finish_cb;
	wa_anim_deleted_cb deleted_cb;
	wa_anim_get_value_cb get_value_cb;
	void* user_data;
	wa_anim_path_cb path_cb;
	int32_t start_value;
	int32_t current_value;
	int32_t end_value;
	int32_t time_long;
	int32_t current_time;
	uint32_t playback_delay;
	uint32_t playback_time;
	uint32_t repeat_delay;
	uint16_t repeat_cnt;

	wa_result early_apply;
	wa_result playback_now;
	wa_result run_round;
	wa_result start_cb_called;
}wa_anim;

/**********************
* GLOBAL PROTOTYPES
**********************/
void wa_anim_module_init(void);
wa_anim* wa_anim_create(void);
void wa_anim_del(wa_anim* anim);
void wa_anim_start(wa_anim* anim);
void wa_anim_set_var(wa_anim* anim, void* var);
void wa_anim_set_exec_cb(wa_anim* anim, wa_anim_exec_xcb cb);
void wa_anim_set_start_cb(wa_anim* anim, wa_anim_start_cb cb);
void wa_anim_set_finish_cb(wa_anim* anim, wa_anim_finish_cb cb);
void wa_anim_set_deleted_cb(wa_anim* anim, wa_anim_deleted_cb cb);
void wa_anim_set_get_value_cb(wa_anim* anim, wa_anim_get_value_cb cb);
void wa_anim_set_path_cb(wa_anim* anim, wa_anim_path_cb cb);
void wa_anim_set_custom_exec_cb(wa_anim* anim, wa_anim_custom_exec_cb cb);
void wa_anim_set_user_data(wa_anim* anim, void* user_data);
void wa_anim_set_values(wa_anim* anim, int32_t start, int32_t end);
void wa_anim_set_time_long(wa_anim* anim, int32_t time_long);
void wa_anim_set_delay(wa_anim* anim, int32_t delay);
void wa_anim_set_playback_time(wa_anim* anim, uint32_t time);
void wa_anim_set_playback_delay(wa_anim* anim, uint32_t delay);
void wa_anim_set_repeat_delay(wa_anim* anim, uint32_t delay);
void wa_anim_set_repeat_cnt(wa_anim* anim, uint16_t cnt);
void wa_anim_set_early_apply(wa_anim* anim, wa_result early_apply);
uint32_t wa_anim_get_remain_time(wa_anim* anim);
void wa_anim_refr_now(void);
void wa_anim_del_all(void);
int32_t wa_anim_path_linear(const wa_anim* a);
int32_t wa_anim_path_ease_in(wa_anim* a);
int32_t wa_anim_path_ease_out(wa_anim* a);
int32_t wa_anim_path_ease_in_out(wa_anim* a);
int32_t wa_anim_path_overshoot(wa_anim* a);
int32_t wa_anim_path_bounce(wa_anim* a);


/**********************
*      MACROS
**********************/

#endif

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif 

